import service from "@/config/index";
import { API, createApis } from "../fulfill";

export const SCHEMAS = {
  certChainEvidence: new API({
    url: "/cert/certChainEvidence/${orderId}",
    method: "GET"
  }),
  certPosition: new API({
    url: "/cert/certChainEvidence/position/${orderId}/${page}/${size}",
    method: "GET"
  }),
  certCheckDownload: new API({
    url: "/cert/download",
    method: "POST"
  }),
  certImage: new API({
    url: "/cert/image/${certId}",
    method: "GET"
  }),
  certCount: new API({
    url: "/cert/countCert",
    method: "GET"
  }),
  certBaseImage: new API({
    url: "/cert/baseImage/${certId}",
    method: "GET"
  })
}

const APIS = createApis(service.serviceCert, SCHEMAS);

export default {
  // 获取订单证书证据链信息
  getCertChainEvidence (orderId) {
    return APIS.certChainEvidence({ variables: { orderId } });
  },
  // 获取订单证书轨迹信息
  getCertPosition (orderId, page, size) {
    return APIS.certPosition({ variables: { orderId, page, size } });
  },
  // 下载证书
  getCertCheckDownload (data) {
    return APIS.certCheckDownload({ data })
  },
  // 证书预览
  getCertImage (certId) {
    return APIS.certImage({ variables: { certId } })
  },
  // 查询数字化回单单数
  getCertCount () {
    return APIS.certCount({ variables: {} })
  },
  getCertBaseImage (certId) {
    return APIS.certBaseImage({ variables: { certId } })
  }
}